/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.binding.beanSpec;

/**
 * Interface describing a status of a bean and it's properties.
 * 
 * @param <T> The owner type
 * @author M. Hautle
 */
public interface IBeanStatus<T> {
	/** Property for the status of the bean */
	public static final String BEAN_STATUS = "BeanStatus";

	/** Property for the status of the bean structure (Bean with all it's children) */
	public static final String BEAN_STRUCTURE_STATUS = "BeanStructureStatus";

	/**
	 * Returns the bean status
	 * 
	 * @return The bean status
	 */
	public Status getStatus();

	/**
	 * Returns the beanstructure status
	 * 
	 * @return The beanstructure status
	 */
	public Status getStructureStatus();

	/**
	 * Returns the bean owning this status object.
	 * 
	 * @return The bean
	 */
	public T getOwner();

	/**
	 * Returns the status of the property with the given name
	 * 
	 * @param property The name of the property
	 * @return The status of the property
	 */
	public Status getStatus(final String property);

	/**
	 * Sets the status of the given property
	 * 
	 * @param property The property name
	 * @param flag The status to set
	 */
	public void setStatus(final String property, final BeanStatusFlag flag);

	/**
	 * Sets the status of the given property
	 * 
	 * @param property The property name
	 * @param flag The status to set
	 * @param message The message or null
	 */
	public void setStatus(final String property, final BeanStatusFlag flag, final String message);

	/**
	 * Sets the given bean status and resets all property status fields!
	 * 
	 * @param flag The status to set
	 * @param message The message to set
	 */
	public void forceBeanStatus(final BeanStatusFlag flag, final String message);

	/**
	 * Resets the initial values to the current values
	 */
	public void clearInitialValues();

	/**
	 * Resets the initial values to the current values and resets the property states (if desired).
	 * 
	 * @param resetState True if the state of all properties should be set to {@link BeanStatusFlag#UNCHANGED}
	 */
	public void clearInitialValues(boolean resetState);

	/**
	 * Resets the properties of this bean to their initial value.
	 * 
	 * @throws ResetException If something went wrong
	 */
	public void resetToInitialValues() throws ResetException;
}
